<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     pagizer
 * @subpackage  website
 */

class m_website_actions_block_AjaxGetBlocksAction extends m_backoffice_extends_Action
{
	public function execute()
	{
        $lang = $this->getContextLang();
        
        $cache = f_core_Cache::getInstance();
        $moduleName = $this->getRequestParameter('moduleName');

        if($cache->hasCache('dragndrop/menu'))
        {
            $result = $cache->getCacheContent('dragndrop/menu');
            if(!isset($result[$moduleName]['blocks']))
            {
                $result = m_website_services_PageService::getInstance()->getBlocksXmlParameters($this->getContextLang());
            }
        }
        else
        {
            $result = m_website_services_PageService::getInstance()->getBlocksXmlParameters($this->getContextLang());
        }

        $this->addToModel('blocks', $result[$moduleName]['blocks']);

		$this->setView('success');
	}	
}